package com.likeyoudo.common.constant;

import static android.content.Context.MODE_PRIVATE;

import com.blankj.utilcode.util.CacheMemoryStaticUtils;
import com.blankj.utilcode.util.SPUtils;

/**
 * @author LikeYouDo
 * @date 2023/12/25 15:28
 */
public class LoginInfoSP {

    /**
     * 实例的key值
     */
    public static final String LOGIN_INFO = "loginInfo";

    /**
     * String
     */
    public static final String TOKEN = "token";

    /**
     * String
     */
    public static final String LOGIN_USER_NAME = "loginUserName";

    /**
     * String
     */
    public static final String LOGIN_USER_PWD = "loginUserPwd";

    /**
     * Boolean
     */
    public static final String REMEMBER_ME = "rememberMe";

    public static SPUtils getSPUtils() {
        return SPUtils.getInstance(LOGIN_INFO, MODE_PRIVATE);
    }

    public static void clearToken() {
        getSPUtils().remove(TOKEN, true);
        // 清除token缓存
        CacheMemoryStaticUtils.remove(LoginInfoSP.TOKEN);
    }
}
